<template>
  <div class="app-container">
    <el-form :inline="true" :model="formdata" ref="formdata" class="box01">
      <el-form-item label="手机号:" prop="uTelephone">
        <el-input v-model="formdata.uTelephone" placeholder="请输入手机号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="select(formdata.uTelephone)">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="Mo" border fit highlight-current-row>
      <el-table-column align="center" label="ID" prop="id" width="95">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="手机号" prop="uTelephone" width="95" align="center">
        <template slot-scope="scope">
          {{ scope.row.uTelephone}}
        </template>
      </el-table-column>
      <el-table-column label="昵称"  prop="uAlias" width="95" align="center">
        <template slot-scope="scope">
          {{ scope.row.uAlias }}
        </template>
      </el-table-column>
      <el-table-column label="真实姓名"  prop="uName" width="95" align="center">
        <template slot-scope="scope">
          {{ scope.row.uName}}
        </template>
      </el-table-column>
      <el-table-column  label="性别"  prop="uSex" width="95" align="center">
        <template slot-scope="scope">
          {{ scope.row.uSex==1?'男':'女'}}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="uMail" label="邮箱" width="200">
        <template slot-scope="scope">
          {{ scope.row.uMail }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="danger" round @click="dele(scope.row.uTelephone)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--      <pagination v-show="total>0" :total="total" :page.sync="listQuery.curPage" :limit.sync="listQuery.pageSize" @pagination="fetchData" />-->
  </div>

</template>

<script>
    export default {
        data() {
            return {
                Mo: [{
                    id:1,
                    uTelephone:"131231",
                    uAlias:"张三",
                    uName:"尼古拉斯",
                    uSex:"男",
                    uMail:"12513@qq.com"
                },
                    {
                        id: 1,
                        uTelephone: "131231",
                        uAlias: "张三",
                        uName: "尼古拉斯",
                        uSex:  "男",
                        uMail: "12513@qq.com"
                    }],
                formdata: {
                    uTelephone: ''
                }
                // listQuery: {
                //   curPage: 1,
                //   pageSize: 2
                // },
                // total: 0
            }
        },

        created() {
            this.fetchData()
        },
        methods: {
            fetchData() {
                var vm = this
                this.axios({
                    url: 'http://localhost:81/api/user/list',
                    params: this.listQuery
                }).then(function(res) {
                    if (res.data.success) {
                        vm.Mo = res.data.data
                        console.log(vm.Mo)
                    }
                })
            },
            dele(uTelephone){
                var vm = this
                this.axios({
                    url: 'http://localhost:81/api/user/delete',
                    params:{ uTelephone: uTelephone }
                }).then(function(res) {
                    if (res.data.success){
                        console.log(res.data.success)
                        vm.$message({
                            type: 'success',
                            message: '删除成功',
                        });
                        window.location.reload();
                    }
                })
            },
            select(formdata){
                console.log(formdata)
                var vm = this
                this.axios({
                    url: 'http://localhost:81/api/user/query',
                    params:{uTelephone:formdata}
                }).then(function(res){
                    if (res.data.success) {
                        vm.Mo = res.data.data
                        console.log("====="+vm.Mo)
                    }
                })
            }
        }
    }
</script>
<style scoped>
  .box01{
    float: left;
    margin-left: 160px;
  }
</style>
